package com.yf.zzmusic.pojo.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.time.ZoneOffset;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotNull;

/**
 * <p>
 * 歌单记录表，为减少music_collec表的数据的冗余
 * </p>
 *
 * @author
 * @since 2024-02-26
 */
@Getter
@Setter
@TableName("music_collect_record")
public class MusicCollectRecord implements Serializable {

  private static final long serialVersionUID = 1L;

  /**
   * 歌曲收藏记录id
   */
  @TableId(value = "music_collect_record_id", type = IdType.AUTO)
  private Integer musicCollectRecordId;

  /**
   * 音乐id
   */
  @NotNull(message = "musicId不能为空")
  private Integer musicId;

  /**
   * 歌单id
   */
  @NotNull(message = "musicCollectId不能为空")
  private Integer musicCollectId;

  /**
   * 创建时间
   */
  @DateTimeFormat(pattern = "yyyy-MM-dd")
  @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
  private LocalDateTime createTime;

  public Long getCreateTime() {
    if (createTime!=null){
      long timestamp = createTime.toInstant(ZoneOffset.of("+8")).toEpochMilli();
      return timestamp;
    }else{
      return null;
    }

  }

  public void setCreateTime(LocalDateTime createTime) {
    this.createTime = createTime;
  }
}
